<?php
/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2020/6/26
 * Time: 20:30
 */

namespace app\common\behavior;
use app\task\model\Setting as SettingModel;
use app\common\library\sms\Driver as SmsDriver;

class SmsBehavior
{
    public function afterPay(&$order)
    {
        // 发送短信通知
        $this->sendSms($order['wxapp_id'], $order['order_no']);
    }

    /**
     * 发送短信通知
     * @param $wxapp_id
     * @param $order_no
     * @return mixed
     * @throws \think\Exception
     */
    private function sendSms($wxapp_id, $order_no)
    {
        // 短信配置信息
        $config = SettingModel::getItem('sms', $wxapp_id);
        $SmsDriver = new SmsDriver($config);
        return $SmsDriver->sendSms('order_pay', compact('order_no'));
    }
}